<#if model??>
package ${model.packageName}.${model.model}<#if model.subModel??>.${model.subModel}</#if>.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.raising.framework.controller.BaseController;
import com.raising.framework.entity.ResultVo;
import com.raising.framework.mybaits.Page;

import ${model.packageName}.${model.model}<#if model.subModel??>.${model.subModel}</#if>.entity.${model.className}Entity;
import ${model.packageName}.${model.model}<#if model.subModel??>.${model.subModel}</#if>.service.${model.className}Service;

/**
 * ${model.tableDesc} 控制器
 * @author ${model.authorNm}
 * @createTime ${model.createTime}
 */
@RestController
@RequestMapping("/${model.model}<#if model.model!=model.className?uncap_first>/${model.className?uncap_first}</#if>")
public class ${model.className}Controller extends BaseController {

    @Autowired
    private ${model.className}Service ${model.className?uncap_first}Service;

    /**
     * 分页 - 查询
     * @author ${model.authorNm}
     * @datetime ${model.createTime}
     * @param page
     * @param ${model.className?uncap_first}
     * @return ResultVo
     */
    // @RequiresPermissions("${model.model}<#if model.model!=model.className?uncap_first>:${model.className?uncap_first}</#if>:select")
    @GetMapping("/page")
    public ResultVo page(${model.className}Entity ${model.className?uncap_first},Page<${model.className}Entity> page) {
        page.setEntity(${model.className?uncap_first});
        ResultVo resultVo = ${model.className?uncap_first}Service.getPage(page);
        ResultVo.entityNull(resultVo);
        return resultVo;
    }

    /**
     * 详情 - 查询
     * @author ${model.authorNm}
     * @datetime ${model.createTime}
    <#list model.columns as column>
        <#if column.key=="PRI">
     * @param ${column.columnName} ${column.columnDesc}
        </#if>
    </#list>
     * @return ResultVo
     */
    // @RequiresPermissions("${model.model}<#if model.model!=model.className?uncap_first>:${model.className?uncap_first}</#if>:select")
    @GetMapping("/info")
    public ResultVo info(<#list model.columns as column><#if column.key=="PRI">@RequestParam("${column.columnName}") String ${column.columnName}</#if></#list>) {
        return ${model.className?uncap_first}Service.get(<#list model.columns as column><#if column.key=="PRI">${column.columnName}</#if></#list>);
    }

    /**
     * 新增 - 插入
     * @author ${model.authorNm}
     * @datetime ${model.createTime}
     * @param ${model.className?uncap_first}
     * @return ResultVo
     */
    // @RequiresPermissions("${model.model}:${model.className?uncap_first}:insert")
    @PostMapping("/insert")
    public ResultVo insert(${model.className}Entity ${model.className?uncap_first}) {
        ${model.className}Entity insert = new ${model.className}Entity();
        //赋值至 insert 对象
    <#list model.columns as column>
        insert.set${column.columnName?cap_first}(${model.className?uncap_first}.get${column.columnName?cap_first}());
    </#list>
        ResultVo resultVo = ${model.className?uncap_first}Service.insert(insert);
    <#list model.columns as column>
        <#if column.key=="PRI">
        resultVo.setData(insert.get${column.columnName?cap_first}());
        </#if>
    </#list>
        return resultVo;
    }

    /**
     * 更新
     * @author ${model.authorNm}
     * @datetime ${model.createTime}
     * @param ${model.className?uncap_first}
     * @return ResultVo
     */
    // @RequiresPermissions("${model.model}:${model.className?uncap_first}:update")
    @PostMapping("/update")
    public ResultVo update(${model.className}Entity ${model.className?uncap_first}) {
        ${model.className}Entity update = new ${model.className}Entity();
        //赋值至 update 对象
    <#list model.columns as column>
        update.set${column.columnName?cap_first}(${model.className?uncap_first}.get${column.columnName?cap_first}());
    </#list>
        return ${model.className?uncap_first}Service.update(update);
    }

    /**
     * 删除
     * @author ${model.authorNm}
     * @datetime ${model.createTime}
    <#list model.columns as column>
        <#if column.key=="PRI">
     * @param ${column.columnName} ${column.columnDesc}
        </#if>
    </#list>
     * @return ResultVo
     */
    // @RequiresPermissions("${model.model}:${model.className?uncap_first}:delete")
    @PostMapping("/delete")
    public ResultVo delete(<#list model.columns as column><#if column.key=="PRI">@RequestParam("${column.columnName}") String ${column.columnName}</#if></#list>) {
        return ${model.className?uncap_first}Service.delete(<#list model.columns as column><#if column.key=="PRI">${column.columnName}</#if></#list>);
    }

}
</#if>